﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Enterprise.Service.User;
using Enterprise.Model.User;
using Enterprise.Infrastructure;
namespace Enterprise.UI.Web
{
    public partial class Login : System.Web.UI.Page
    {
        int LoginType = (int)Utility.sink("LoginType", Utility.MethodType.Get, 0, 0, Utility.DataType.Int);
        //腾讯通登录需要获取的信息
        //解密处理
        string user = (string)Utility.sink("user", Utility.MethodType.Get, 0, 0, Utility.DataType.Str);
        string sign = (string)Utility.sink("sign", Utility.MethodType.Get, 0, 0, Utility.DataType.Str);
        protected void Page_Load(object sender, EventArgs e)
        {
            if (LoginType == 1)
            {
                UserLoginService logService = new UserLoginService();
                bool rbool = logService.EnterpriseLogin(user, sign, 0);
                if (rbool)
                {
                    Session["language"] = "zhcn";
                    Response.Redirect("Default.aspx");
                    Response.End();
                }
                else
                {
                    Response.Redirect("Login.aspx");
                    Response.End();
                }
            }
        }

        protected void BtnLogin_Click(object sender, EventArgs e)
        {
            string sName = (string)Utility.sink(UserName.UniqueID, Utility.MethodType.Post, 0, 0, Utility.DataType.Str);
            string sPassword = (string)Utility.sink(Password.UniqueID, Utility.MethodType.Post, 0, 0, Utility.DataType.Str);
            UserLoginService logService = new UserLoginService();
            bool rbool = logService.EnterpriseLogin(sName, sPassword, 1);
            if (rbool)
            {
                Session["language"] = Language.SelectedValue;//语言
                Response.Redirect("Default.aspx");
                Response.End();
            }
            else
            {
                Response.Redirect("Login.aspx");
                Response.End();
            }
        }
    }
}